<?php
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <?php foreach($data as $key=>$value):?>
        <div style="float: left;margin-right: 20px">
           <span>
               <p id="h<?php echo $value['id']?>"></p>时
               <p id="h<?php echo $value['id']?>"></p>分
               <p id="h<?php echo $value['id']?>"></p>秒
           </span>
            <p><img src="<?php echo $value['img']?>" alt="" width="350" height="200"></p>
            <p><?php echo $value['price']?></p>
            <p><?php echo $value['name']?></p>
            <p><input type="button" class="save" value="抢购" id="<?php echo $value['id']?>"></p>
        </div>
    <?php endforeach;?>
</body>
</html>
<script src="jquery-3.3.1.min.js"></script>
<script>
    $(document).on("click",".save",function(){
       var id = $(this).attr('id')

        $.ajax({
            url:"?r=seck/index_do";
            data:{id:id},
            dataType:"json",
            type:"get",
            success:function(res)
            {
                if(res['code']==1)
                {
                    alert(res['msg'])
                }else{
                    alert(res['msg'])
                }
            }
        })
    })
</script>
